package com.example.practical_training_projects.mapper;

import com.example.practical_training_projects.entity.user;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface userMapper {
    @Select("select * from user")
    List<user> getAlluser();
    @Insert("insert into user (picture,user_name,user_password,user_grade,user_grade2,user_grade3,healthLevel1,healthLevel2,healthLevel3,user_sex,user_email,user_phone,user_power)\n" +
            " values (#{picture},#{user_name},#{user_password},#{user_grade},#{user_grade2},#{user_grade3},#{healthLevel1},#{healthLevel2},#{healthLevel3},#{user_sex},#{user_email},#{user_phone},#{user_power})")
    Integer insertUser(user user_uid);

    @Delete("delete from user where user_uid=#{user_uid}")
    Integer deleteUser(Integer user_uid);


    @Select("select * from user where user_name = #{user_name} and user_password = #{user_password}")
    user authenticateUser(@Param("user_name") String username, @Param("user_password")String password);

    @Update("update user set picture=#{picture},user_name=#{user_name},user_password=#{user_password},user_sex=#{user_sex},user_grade=#{user_grade},user_grade2=#{user_grade2},user_grade3=#{user_grade3},healthLevel1=#{healthLevel1},healthLevel2=#{healthLevel2},healthLevel3=#{healthLevel3},user_email=#{user_email},user_phone=#{user_phone} where user_uid = #{user_uid}")
    Integer updateUser(user user1);

    @Select("select *from user where user_name like '%${name}%'")
    List<user>  getuserBYName(String user_name);

    @Select("select * from  user where user_uid = #{user_uid}")
    user findUseruid(Integer user_uid);
    //分页
    @Select("  SELECT * FROM user\n" +
            "    ORDER BY user_uid\n" +
            "    LIMIT #{limit} OFFSET #{offset}")
    user getUserList(@Param("offset") int page, @Param("limit") int limit);







}
